/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package lianxishilili.demo;

/**
 *
 * @author Administrator
 */
public class IdNumber {
    public static void main(String[] args) {
        String idnumber="123456789123456789";
        boolean flag=true;
        if(idnumber.length()!=18){
            flag=false;
        }
        if(!(idnumber.startsWith("0")||idnumber.startsWith("1"))){
            flag=false;
        }
        String numstr="01234567891011121314151617";
        for(int i=0;i<idnumber.length();i++){
        char c=idnumber.charAt(i);
        int temp=idnumber.indexOf(c);
        if(temp<0){
        flag=false;
        break;
        }
        }
        if(flag){
            System.out.println("是合法的身份证号");
        }
        else{
            System.out.println("不是合法的身份证号");
        }
    }
}
